query ( "SELECT * FROM uploader_pfiles WHERE file_id=$file_id LIMIT 1" ); if ( $result->numRows() ) { $file = array(); $upload_set = array(); $previous_file = array(); $next_file = array(); // get file $file = $result->fetchRow('assoc'); processPublicFile ( $file ); $result->free(); // get upload set $result = $mysqlDB->query ( "SELECT * FROM uploader_puploads WHERE upload_id={$file['upload_id']} LIMIT 1" ); $upload_set = $result->fetchRow('assoc'); processPublicSet ( $upload_set ); $result->free(); // is file really an image? if(!$file['file_isimage'])exit(go_to($file['url'])); // output $tpl_view = new Template ( TPL_DIR . 'tpl_public_view_image_full.php' ); $tpl_view->setr ( 'file', $file ); $tpl_view->setr ( 'upload_set', $upload_set ); $tpl_view->set ( 'page_title', $file['file_name'] ); $tpl_view->display(); } else { $tpl_message->set ( 'message', $lang_public['file_not_found'] ); $tpl_uploader->set ( 'page_title', $lang_public['title_file_not_found'] ); $tpl_uploader->set ( 'content', $tpl_message, true ); exit; } } else { $file_id = (int)gpc ( 'file_id', 'G', 0 ); $result = $mysqlDB->query ( "SELECT * FROM uploader_pfiles WHERE file_id=$file_id LIMIT 1" ); if ( $result->numRows() ) { $file = array(); $upload_set = array(); $previous_file = array(); $next_file = array(); // get file $file = $result->fetchRow('assoc'); processPublicFile ( $file ); $result->free(); // get upload set $result = $mysqlDB->query ( "SELECT * FROM uploader_puploads WHERE upload_id={$file['upload_id']} LIMIT 1" ); $upload_set = $result->fetchRow('assoc'); processPublicSet ( $upload_set ); $result->free(); // is file really an image? if(!$file['file_isimage'])exit(go_to($file['url'])); // get total images in this set $upload_set['total_images'] = 0; $result = $mysqlDB->query ( "SELECT COUNT(file_id) AS total_images FROM uploader_pfiles WHERE upload_id={$file['upload_id']} AND file_isimage=1" ); if ( $result->numRows() ) { $row = $result->fetchRow('assoc'); $result->free(); $upload_set['total_images'] = $row['total_images']; } // get position $file['position'] = 0; $result = $mysqlDB->query ( "SELECT COUNT(file_id) AS position FROM uploader_pfiles WHERE upload_id={$file['upload_id']} AND file_isimage=1 AND file_id<{$file['file_id']}" ); if ( $result->numRows() ) { $row = $result->fetchRow('assoc'); $result->free(); $file['position'] = $row['position']+1; } // previous $result = $mysqlDB->query ( "SELECT * FROM uploader_pfiles WHERE file_id < {$file['file_id']} AND upload_id={$upload_set['upload_id']} AND file_isimage=1 ORDER BY file_id DESC LIMIT 1" ); if ( $result->numRows() ) { $previous_file = $result->fetchRow('assoc'); $result->free(); processPublicFile($previous_file); } // next $result = $mysqlDB->query ("SELECT * FROM uploader_pfiles WHERE file_id > {$file['file_id']} AND upload_id={$upload_set['upload_id']} AND file_isimage=1 ORDER BY file_id ASC LIMIT 1"); if ( $result->numRows() ) { $next_file = $result->fetchRow('assoc'); $result->free(); processPublicFile($next_file); } // output $tpl_view = new Template ( TPL_DIR . 'tpl_public_view_image.php' ); $tpl_view->setr ( 'file', $file ); $tpl_view->setr ( 'upload_set', $upload_set ); $tpl_view->setr ( 'previous_file', $previous_file ); $tpl_view->setr ( 'next_file', $next_file ); $tpl_view->set ( 'page_title', $file['file_name'] ); $tpl_view->display(); } else { $tpl_message->set ( 'message', $lang_public['file_not_found'] ); $tpl_uploader->set ( 'page_title', $lang_public['title_file_not_found'] ); $tpl_uploader->set ( 'content', $tpl_message, true ); exit; } } ?>